1. Field of the Invention
The present invention relates to a method to prevent a flash memory in a computer system from being miswritten, the method including a check module to confirm that the writing of the flash memory is from normal paths of a process module.
2. Description of the Related Art
Because a flash memory can be provided in a computer system to modify its firmware by end users, it is very convenient for both manufacturers and Internet users to update the firmware. Additionally, it is also economical to rework the flash memory. Therefore, the flash memory has been widely used to replace the conventional erasable and programmable read only memory (EPROM), which has to be written in advance and can not be modified.
However, it is possible that the flash memory is miswritten under certain situations, such as transience of the power supply, an unstable power supply or unstable control signals. In these cases, part or all of the data stored in the flash memory can be destroyed, resulting in unintended coding.
In practice, a large percentage of flash memories, even made by different methods or made of different materials, can be miswritten under these situations.
The Central Processing Unit (CPU) often operates in response to the data stored in the flash memory for control of the operating system (OS) and computer security. Once a flash memory is miswritten, unexpected errors may occur. Further, the damage to the flash memory causing such unexpected errors is permanent and can not be recovered by restarting the computer system.
Thefore, it is an object of the present invention to provide a method for preventing a flash memory in a computer system from being miswritten which can ensure the security of the flash memory using firmware modifications only.
It is another object of the present invention to provide a method to prevent a flash memory in a computer system from being miswritten which can ensure the security of the flash memory without any circuit modifications, thus requiring no increase in hardware and little increase in time.
To realize the above and other objects, the present invention provides a method to prevent a flash memory in a computer system from being miswritten. A first embodiment of the present invention includes the steps of executing a process module provided with a control parameter recording its normal paths, the control parameter being incremented for each executed step, executing a judge module to determine whether or not the flash memory is to be written. When the judge module determines the flash memory is to be written after the process module, a prepare module is executed to prepare the flash memory for writing. Then a check module is executed to confirm that the writing of the flash memory is from the normal paths of the process module by comparing the control parameter with a confirmation value, and a write module is executed to provide the flash memory when the check module confirms that the writing of the flash memory is from the normal paths of the process module.
In the method of the present invention, an error module can also be provided to restart the process module when the check module does not confirm that the writing of the flash memory is from the normal paths of the process module,
Alternatively, in the method of the present invention, the error module can restart the computer system or generate a warning signal.
Further, the present invention also provides a method used to prevent a flash memory in a computer system from being miswritten. In accordance with a second embodiment of the present invention, a first module and a second module are first executed with a first parameter and a second parameter recording their normal paths respectively. Then, a judge module is provided to decide whether or not the flash memory is to be written after the first module or the second modules. When the judge module decides the flash memory id to be written after the first module or the second module, a prepare module is first provided to conduct preparations for the flash memory, then a check module is provided to confirm the normal paths for the first module or the second module, and a write module is provided to write the flash memory when the check module confirms the normal paths from the first module or the second module.